<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	template="/WEB-INF/templates/template.xhtml">
<head>
<h:outputStylesheet name="css/template.css" />
</head>	
	
<ui:define name="title">
		<h3><h:outputLabel	value="#{i18n['erp.matricula.materia.pagina.titulo']}" /></h3>
	</ui:define>	

	
<ui:define name="content">
		<h:form id="formMateria">
		
			<p:growl id="pnlMessages" autoUpdate="true" closable="true"/>
			
			<p:toolbar>
				<p:toolbarGroup align="left">
					<p:commandButton id="btnRefrescar" value="Refrescar" icon="ui-icon-arrowrefresh-1-w" >
					</p:commandButton>
					<p:commandButton type="sumit" id="btnNuevaMateria" title="Nueva Materia" value="Insertar" icon="ui-icon ui-icon-circle-plus" oncomplete="dlgNuevaMateria.show()">
						</p:commandButton>
				</p:toolbarGroup>
			</p:toolbar>
			<p:panel id="pnlBuscarMateria" header="#{i18n['erp.matricula.materia.buscar']}"  style="width: 700px;" toggleable="true">
				<table class="formulario">
					<tr >
						<td  align="right"><h:outputLabel value="#{i18n['erp.matricula.materia.nombre']}:" /> </td>
					<td class="value">
							<p:inputText id="txtNombreBuscar"  style="width: 450px;" title="Filtra por el Nombre de Materia "
								value="#{materiaDataManager.materiaBuscar.mtrNombe}" />
						</td>
						<td>
						<p:commandButton id="btnBuscar"
					actionListener="#{materiaController.buscarMateria}"
					value="#{i18n['label.buscar']}" 
					 icon="ui-icon-search"
                     title="Buscar"
					process="@this,pnlBuscarMateria"
					update=":formMateria:pnlMessages,tablaMateria,pnlBuscarMateria" />
						</td>
					
					</tr>
				</table>
			</p:panel>

<p:panel id="botonesBuscar">
				
			</p:panel>

<p:dataTable id="tablaMateria"
	value="#{materiaDataManager.materiaDTOs}" var="materias"
	rowIndexVar="rowIndex"
	paginator="true" rows="5" paginatorPosition="bottom"
	paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
	rowsPerPageTemplate="5,10,15" emptyMessage="#{i18n['erp.matricula.materia.lista']}">
	<f:facet name="header">
		#{i18n['erp.matricula.materia.lista']}
	</f:facet>
	<p:column headerText="#" styleClass="centered" width="5%">
		#{rowIndex+1}
	</p:column>
<p:column headerText="#{i18n['erp.matricula.materia.nombre']}" width="35%">
					<h:outputText value="#{materias.mtrNombe}" />
				</p:column>
				<p:column headerText="#{i18n['label.opciones']}" styleClass="centered" width="10%">
					<h:panelGroup>
						<p:commandLink styleClass="no-decor"
							title="#{i18n['label.editar']}"
							oncomplete="dlgEditarMateria.show()"
							actionListener="#{materiaController.cargarDatosMateria(materias)}"
							process="@this" update=":formEditarMateria:pnlEditarMateria">
							<h:graphicImage value="/resources/img/edit.png" alt="#{i18n['label.editar']}"/>
						</p:commandLink>
						<p:commandLink styleClass="no-decor"
							title="Eliminar Materia" oncomplete="dlgEliminar.show()">
							<f:setPropertyActionListener target="#{materiaController.codMateria}" value="#{materias.mtrCodigo}" />
							<h:graphicImage value="/resources/img/delete.gif" alt="Eliminar"/>
						</p:commandLink>
					</h:panelGroup>
					</p:column>
								
			</p:dataTable>	
			<!-- Delete Materia -->
			<p:confirmDialog id="dlgEliminar" width="400" widgetVar="dlgEliminar"
				message="Desea eliminar la materia seleccionada?"
				header="Eliminar Materia" appendTo="@(body)">
				<p:commandButton value="#{i18n['label.aceptar']}"
					actionListener="#{materiaController.eliminarMateria()}"
					oncomplete="dlgEliminar.hide()"
					update=":formMateria:pnlMessages,tablaMateria" process="@this"
					styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
				<p:commandButton value="#{i18n['label.cancelar']}" type="button" 
					onclick="dlgEliminar.hide()" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
			</p:confirmDialog>		
	</h:form>			
		
		
<ui:include src="dialogNuevaMateria.xhtml" />	
<ui:include src="dialogEditarMateria.xhtml" />		


			
		
	</ui:define>
</ui:composition>